import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Stomp from  'stompjs'
import SockJS from  'sockjs-client'
import QRCode from 'qrcodejs2'
import html2canvas from 'html2canvas'

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUI);
// 引入组件
// import 自定义组件对象名 from "./components/组件.vue"

Vue.config.productionTip = false
// 将引入组件转为全局组件-(可在项目中任一组件的html中用全局组件标签)
// Vue.component("标签名",自定义组件对象名)

//配置axios
import axios from "axios"
// import axiosWu from "axios"
// axios.defaults.baseURL="/apis"

// axios.defaults.baseURL="https://jbhotel.cklock.cn"//线上消息接口
axios.defaults.baseURL="https://ceshi2.cklock.cn"//测试服务器接口
// axiosWu.defaults.baseURL="https://pay.chienkun.net.cn/api"//吴哥接口，用户，操作日志,优惠券
// axiosWu.defaults.baseURL="https://ceshi1.cklock.cn/8850"//线下，用户，操作日志,优惠券
// axios.defaults.baseURL="http://192.168.0.120:8081"
// axios.defaults.baseURL="http://39.103.141.171:8080"
// axios.defaults.baseURL="http://api.xysyc.cn"

axios.interceptors.request.use(config=>{
  config.headers["Authorization"] = window.sessionStorage.getItem('token');
  config.headers["Content-Type"] = "application/json;charset=UTF-8";
  // if(config.method=="post")
  return config;
})

 
Vue.prototype.axios=axios
// Vue.prototype.axiosWu=axiosWu
  
router.beforeEach((to,from,next)=>{
  if(to.meta.requireAuth){
    console.log(to.meta.requireAuth)
    console.log(store.state.islogin)
    if(store.state.islogin){
      next()
    }else{
      next({path:'/'})
    }
  }else{next()}
})

// 修改页面路由重复点击报错
// const originalPush = router.prototype.push
// router.prototype.push = function push(location) {
//    return originalPush.call(this, location).catch(err => err)
// }

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
